/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.iss.examsys.ejb;

import com.iss.examsys.entity.Module;
import com.iss.examsys.entity.Question;
import com.iss.examsys.entity.User;
import com.iss.examsys.view.AddExamQuestionView;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;

/**
 *
 * @author teng.hui.pei
 */
@Stateless
public class AddExamQuestionBean {
    @PersistenceContext private EntityManager em;
    @EJB private ModuleBean moduleBean;
    
    public void addExamQuestion(AddExamQuestionView addExamQuestionView)
    {
        Question question = new Question();
        
        //em.merge(this)
    }
    
    public List<Module> findAllModule(){
        TypedQuery<Module> result = em.createNamedQuery("Module.findAll", Module.class);
        return result.getResultList();
    }
    
    public List<Module> findAllModuleForLectureId(long userId){
        return moduleBean.findModulesByLecturerId1(userId);
    }
}
